'''
Created on Sep 1, 2011

@author: philip
'''

class TextBlock:
    """
        TextBlock is a block of text within a page
        (corresponds to a "<Para>" element within TETML document)
    """
    def __init__(self, text = ""):
        self.words = []
    
    def add_word(self,word):
        self.words.append(word)
        
    def as_html(self):
        if len(self.words) == 0: return "<p></p>"
        
        text = ""
        
        for word in self.words:
            text = "%s %s" % (text, word.text)
        
        if self.words[0].is_bullet: return "<li>%s</li>" % text
        else : return "<p>%s</p>" % text